$(function(){
    
    var linked = false;
    $(".sidebar a").each(function(){
        
        if (String($(this).attr("href")) == String(window.location)) {
            $(this).addClass("selflink");
            linked = true;
        }
    });
    
    if (!linked) {
        $(".sidebar a").each(function(){
            if (String($(this).attr("href")).indexOf(String(window.location)) !== -1){
                $(this).addClass("selflink");
            }
        });
    }
});

function result_to_ms(result_string) {

    if (result_string.length == 0 || result_string.indexOf('DQ') != -1) {
        return 2147483647;
    }

    var ms = 0.0;
    result_string = result_string.replace(',', '.');
    result_string = result_string.replace('X', '');
    var splits = result_string.split(':');
    if (splits.length == 2) {
        ms += parseInt(splits[0]) * 60 + parseFloat(splits[1]);
    } else if (splits.length == 1) {
        ms += parseFloat(splits[0]);
    } else {
        return 2147483647;
    }

    return ms * 1000.0;
        
}